package com.itmayiedu.service;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

/**
 * *******************************************
 *
 * @description:
 * @author: by jgl
 * @date: 2018/1/30 0030 下午 10:13
 * @version:1.0 *******************************************
 */
@Service
public class HelloSevice {

    @Autowired
    private RestTemplate restTemplate;//使用restTemplate调用接口

    @HystrixCommand(fallbackMethod = "error")
    public String hi(String name) {
        return restTemplate.getForObject("http://service-hi/hi?name=" + name, String.class);
    }

    public String error(String name){
        return "name="+name+"调用service-hi-hi接口，失败了";
    }
}
